package org.fao.pims.web.pollneeds;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.*;

public class PollinationNeedsForm extends ActionForm {
	
	//input attributes
	private String nameofcrop;
	
	//output attributes
	private String scientificName;
	private String commonName;

	public String getNameofcrop() {
		
		return nameofcrop;
	}

	public void setNameofcrop(String nameOfCrop) {
		this.nameofcrop = nameOfCrop;
	}

	public String getScientificName() {
		return scientificName;
	}

	public void setScientificName(String scientificName) {
		this.scientificName = scientificName;
	}

	public String getCommonName() {
		return commonName;
	}

	public void setCommonName(String commonName) {
		this.commonName = commonName;
	}
	
	public void reset(ActionMapping mapping, HttpServletRequest request)
	{
		
		nameofcrop = null;
		
		scientificName = null;
		
		commonName = null;
		
		
	}
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
	{
		ActionErrors errors = new ActionErrors();
		
		
		
		if( (nameofcrop == null) || nameofcrop.trim().equals(""))
		{
			errors.add("nameOfCrop", new ActionMessage("pollinationNeeds.nameOfCrop.blank"));
		}
		
		
		return errors;
	}

	

	

}
